#ifndef SWEGL_INDEX_BUFFER_H
#define SWEGL_INDEX_BUFFER_H

#include "swegl/common.h"

namespace swegl
{

class IndexBuffer
{
public:
	IndexBuffer();
	~IndexBuffer();
	
	enum IndexType
	{
		Index16Bit,
		Index32Bit,
	};

	void init(IndexType indexType, size_t numIndices);
	
	IndexType indexType() const { return m_indexType; }
	size_t numIndices() const { return m_numIndices; }
	
	void *data() { return m_data; }
	template<typename T> T *data();
	
	const void *data() const { return m_data; }
	template<typename T> const T *data() const;
	
	uint8 *m_data;
	size_t m_numIndices;
	IndexType m_indexType;
};

template<typename T>
inline T *IndexBuffer::data()
{
	return static_cast<T *>(data());
}

template<typename T>
inline const T *IndexBuffer::data() const
{
	return static_cast<const T *>(data());
}

}

#endif 
